"""
-------------------------------------------------
   File Name：     test
   Description :
   Author :       DuanZhangjie
   date：         2021-12-23 8:07
-------------------------------------------------
"""


class Base:
    name = 'abc'
    id = None
    __id = None
    __id2 = None

    @classmethod
    def get_id(cls):
        if cls.id is None:
            print('id不存在-------------')
            return None
        if cls.__id is None:
            print('初始化id-----------')
            cls.__id = cls.id
        return cls.__id

    def get_id2(self):
        if self.__id2 is None:
            print('初始化id2-----------')
            self.__id2 = 10
        return self.__id2


class a(Base):
    id = 10
    pass


class b(Base):
    id = 20
    pass


if __name__ == '__main__':
    a1 = a()
    print(a1.get_id())
    print(a1.get_id())
    # print(a1.get_id2())
    # print(a1.get_id2())
    b1 = a()
    print(b1.get_id())
    print(b1.get_id())
    # print(b1.get_id2())
    # print(b1.get_id2())
    b11 = a()
    print(b11.get_id())
    print(b11.get_id())
    b2 = b()
    print(b2.get_id())
    print(b2.get_id())
